package com.SmartClassroom.system.service.impl;

import com.SmartClassroom.system.common.ErrorCode;
import com.SmartClassroom.system.exception.BusinessException;
import com.SmartClassroom.system.mapper.CourseMapper;
import com.SmartClassroom.system.model.domain.Course;
import com.SmartClassroom.system.model.dto.course.CourseQueryRequest;
import com.SmartClassroom.system.model.vo.CourseVO;
import com.SmartClassroom.system.service.CourseService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author baijiayu
 * @description 针对表【Course】的数据库操作Service实现
 * @createDate 2024-11-19 11:01:51
 */
@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> implements CourseService {

    @Autowired
    private CourseMapper courseMapper;

    @Override
    public Page<CourseVO> getQueryWrapper(Page<CourseVO> pageParam, CourseQueryRequest courseQueryRequest) {
        if (courseQueryRequest == null) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数为空");
        }

        // 自定义分页查询
        List<CourseVO> courseList = courseMapper.page(pageParam, courseQueryRequest);

        // 设置分页结果
        pageParam.setRecords(courseList);
        return pageParam;
    }


}




